<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<!-- http://127.0.0.1:8080/company/web/login.jsp -->
<%@ include file="/web/header.jsp" %>
<title>login</title>
</head>
<body>
	<fieldset class="layui-elem-field" style='margin:20px;padding:20px'>
	  <legend>登录</legend>
	  <div class="layui-field-box">
	   	<form class="layui-form layui-form-pane" action="">
		  <div class="layui-form-item">
		    <label class="layui-form-label">账号</label>
		    <div class="layui-input-inline">
		      <input type="text" name="code" required  lay-verify="required" 
		       placeholder="请输入帐号" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">密码框</label>
		    <div class="layui-input-inline">
		      <input type="password" name="psd" required lay-verify="required" 
		       placeholder="请输入密码" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">
		      <img src='/homework/VerifyCodeServlet' onclick="this.src='/homework/VerifyCodeServlet?'+Math.random();"/>
			</label>
		    <div class="layui-input-inline">
		      <input type="text" name="yzm" required  lay-verify="required" placeholder="请输入验证码" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <div class="layui-input-inline">
			  <input type="button" class="layui-btn" lay-submit lay-filter="login" value="确定">		   
		      <input type="reset" class="layui-btn layui-btn-primary" value="重置">
		    </div>
		  </div>
		</form>
	  </div>
</fieldset>
<script type="text/javascript">

	var form=layui.form;
	var layer=layui.layer;
	var $=layui.jquery;
	form.on("submit(login)",function(data){//给按钮加监听，执行方法
		console.log(data.field);
		$.ajax({
			url:base.app+"/h6Servlet",
			type:"post",
			data:data.field,
			dataType:"text",
			success:function(data){ 
				console.log(data);
				if("F"==data){
					layer.msg("验证码错误")
				}else{
					layer.msg("验证码正确")
				}
			}
		})
	})
	
	
</script>
</body>
</html>